// @include "../../scripts/spket.js"

$(function(){
	var request = {
		action: "hello.say",
		params: { name: "Panda" }
	};

	panda.post(request, function(data) {
		$("#message").html(data);
	});

	panda.uploader({
		element: $("#file-uploader")[0],
		params: { action: "hello.upload" },
		sizeLimit: 1000 * 1024 * 1024,
		onComplete: function(file, data){
			$("#attachment_names").append($("#attachment_names_tmpl").tmpl({
				file: file, data: data
			}));

			var $attachment = $("#attachment_" + file.id);
			var $a = $attachment.find("a");
			$a.eq(0).click(function() {
				panda.open({
					action: "hello.download",
					params: { name: $(this).attr("name") }
				});
			});
			$a.eq(1).click(function(){ $attachment.remove(); });
		}
	});
});
